<?php

namespace App\Entity;

use App\Repository\NoticeReadRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=NoticeReadRepository::class)
 * @ORM\Table(options={"comment":"消息已读表"})
 * @ORM\HasLifecycleCallbacks()
 */
class NoticeRead
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="integer", options={"comment":"用户ID"})
     */
    private $admin_user_id;

    /**
     * @ORM\Column(type="integer", options={"comment":"消息ID"})
     */
    private $notice_id;

    /**
     * @ORM\Column(type="string", length=255, nullable=true, options={"comment":"IP地址"})
     */
    private $ip;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $created_at;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $updated_at;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getAdminUserId(): ?int
    {
        return $this->admin_user_id;
    }

    public function setAdminUserId(int $admin_user_id): self
    {
        $this->admin_user_id = $admin_user_id;

        return $this;
    }

    public function getNoticeId(): ?int
    {
        return $this->notice_id;
    }

    public function setNoticeId(int $notice_id): self
    {
        $this->notice_id = $notice_id;

        return $this;
    }

    public function getIp(): ?string
    {
        return $this->ip;
    }

    public function setIp(?string $ip): self
    {
        $this->ip = $ip;

        return $this;
    }

    public function getCreatedAt(): ?\DateTimeInterface
    {
        return $this->created_at;
    }

    public function setCreatedAt(?\DateTimeInterface $created_at): self
    {
        $this->created_at = $created_at;

        return $this;
    }

    public function getUpdatedAt(): ?\DateTimeInterface
    {
        return $this->updated_at;
    }

    public function setUpdatedAt(?\DateTimeInterface $updated_at): self
    {
        $this->updated_at = $updated_at;

        return $this;
    }

    /**
     * 新建之前
     * @ORM\PrePersist()
     */
    public function prePersistHook () {
        // 添加创建时间
        $this->created_at = new \DateTime();
    }

    /**
     * 更新之前
     * @ORM\PreUpdate()
     */
    public function preUpdateHook () {
        // 添加更新时间
        $this->updated_at = new \DateTime();
    }
}
